#include <QtCore/QCoreApplication>
#include <QtSql>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    qDebug() << QSqlDatabase::drivers();
    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("localhost");
    db.setDatabaseName("postgres");
    db.setUserName("postgres");
    db.setPassword("123456");
    bool ok = db.open();
    if(ok)
    {
        qDebug() << "db connect!";
    }

    QSqlQuery query;
    //query.exec("SELECT * FROM Measures");
    if(query.exec("SELECT * FROM USERS")){
        while(query.next()){
            qDebug() << query.value(0).toInt() << "," << query.value(1).toString() <<"," << query.value(2).toString();
        }
        qDebug() << query.lastError().text();
        qDebug() << "Inside First if Statement";
    }
    else
    {
        qDebug() << query.lastError().text();
    }

    return a.exec();
}
